package com.xnck.demo;

import com.xnck.demo.exportword.IExportWord;
import com.xnck.demo.exportword.impl.BTLExportWord;
import com.xnck.demo.exportword.impl.FTLExportWord;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Hello world!
 *
 */
public class App 
{
    private final static int flag = 1;

    public static void main(String[] args)
    {
        Map<String, Object> data = getData();
        IExportWord exportWord;
        if (1 == flag){
            exportWord = new BTLExportWord();
        } else {
            exportWord = new FTLExportWord();
        }
        try {
            exportWord.exportWord("C:\\temp\\test.doc", data);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private static Map<String, Object> getData(){
        Map<String, Object> data = new HashMap<String, Object>();
        data.put("text1", "1111111111111");
        data.put("text2", "2222222222222");
        List<Map<String, Object>> items = new ArrayList<Map<String, Object>>();
        Map<String, Object> item1 = new HashMap<String, Object>(){
            {
                put("key", "测试1");
                put("value", "这是测试1");
            }
        };
        Map<String, Object> item2 = new HashMap<String, Object>(){
            {
                put("key", "测试2");
                put("value", "这是测试2");
            }
        };
        items.add(item1);
        items.add(item2);
        data.put("items", items);
        return data;
    }
}
